package com.itheima.controller;


import com.itheima.domain.User;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController//与@Controller+@ResponseBody联合使用效果相同
// 一级url路径
@RequestMapping("/ajax")
public class AjaxController {

//1.传输字符串
    @RequestMapping("/test1")
    public String test1(String username) {
        System.out.println("ajax success");
        return username;
    }

    //接收json类型 在参数中加入标签@RequestBody 然后注入前端json格式的数据
    @RequestMapping("/test2")
    public String test2(@RequestBody User user) {
        System.out.println(user);
        return "yes";
    }

    //接收传输的键值对形式
    @RequestMapping("/test3")
    public String test3(User user){
        System.out.println(user);
        return "manager";
    }
}
